def chk_prime(n):
    if n>1:
        for i in range(2, n//2+1):
            if n%i==0:
                return False
                break
        else:
            return True
    else:
        return False
    
n = input().split()
#print (n)
digit = ['zero', 'one', 'two', 'three', 'four', 'five', 'six','seven', 'eight', 'nine']
ch = ''
for i in range(3):
    ch += str(digit.index(n[i]))

if ch[0] == '0' or len (ch) != 3:
    print ('Wrong input')
else:
    n=int(ch)
    if chk_prime(n):
        print(n)
    else:
        count =1
        while count < n:
            p1 = n-count
            p2 = n+count
            p1_chk = chk_prime(p1)
            p2_chk = chk_prime(p2)
            if p1_chk and p2_chk:
                print(p1, p2)
                break
            elif p1_chk and not p2_chk:
                print(p1)
                break
            elif p2_chk and not p1_chk:
                print(p2)
                break
            else:
                count  = count + 1
